<?php
// Запрет прямого доступа.
defined('_JEXEC') or die;

// Данные по сортировке.
$listDirn = $this->escape($this->state->get('list.direction'));
$listOrder = $this->escape($this->state->get('list.ordering'));
$saveOrder = $listOrder == 'ordering';

foreach ($this->items as $i => $item) :

    $canEdit = JFactory::getUser()->authorise('core.edit', 'com_calc.calc.' . $item->id);
    $canChange = JFactory::getUser()->authorise('core.edit.state', 'com_calc.calc.' . $item->id);
    ?>
    <tr class="row<?php echo $i % 2; ?>" sortable-group-id="1">
        <td class="order nowrap center hidden-phone">
            <?php
            $iconClass = '';
            if (!$canChange) {
                $iconClass = ' inactive';
            } elseif (!$saveOrder) {
                $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
            }
            ?>
            <span class="sortable-handler<?php echo $iconClass ?>">
                <i class="icon-menu"></i>
            </span>
            <?php if ($canChange && $saveOrder) : ?>
                <input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
            <?php endif; ?>
        </td>

        <td class="center hidden-phone">
            <?php echo JHtml::_('grid.id', $i, $item->id); ?>
        </td>

        <td class="center">
            <div class="btn-group">
                <?php echo JHtml::_('jgrid.published', $item->state, $i, 'calcs.', $canChange, 'cb'); ?>
                <?php
                // Create dropdown items
                $action = $archived ? 'unarchive' : 'archive';
                JHtml::_('actionsdropdown.' . $action, 'cb' . $i, 'articles');

                $action = $trashed ? 'untrash' : 'trash';
                JHtml::_('actionsdropdown.' . $action, 'cb' . $i, 'articles');

                // Render dropdown list
                echo JHtml::_('actionsdropdown.render', $this->escape($item->title));
                ?>
            </div>
        </td>        

        <td>
            <?php if ($canEdit) : ?>
                <a href="<?php echo JRoute::_('index.php?option=com_calc&task=calc.edit&id=' . (int) $item->id); ?>">
                    <?php echo $this->escape($item->caption); ?>
                </a>
                <?php
            else :
                echo $this->escape($item->caption);
            endif;
            ?>
        </td>
        <td>
            <?php echo $item->description; ?>
        </td>
        <td>
            <?php echo $item->formula; ?>
        </td>

        <td class="center hidden-phone">
            <?php echo (int) $item->id; ?>
        </td>

    </tr>
<?php endforeach; ?>